/*     */ package com.qmsk.business.store.supplier.controller;
/*     */ 
/*     */ import com.qmsk.business.store.supplier.dao.SupplierDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"supplier"})
/*     */ public class SupplierController
/*     */ {
/*  42 */   private static final Logger logger = Logger.getLogger(SupplierController.class);
/*     */ 
/*     */   @Autowired
/*     */   private SupplierDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  52 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  54 */       Map params = new HashMap();
/*     */ 
/*  56 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  57 */       MapUtils.addPercentToMap(params, "code", 
/*  58 */         RequestUtils.getString(request, "code"));
/*  59 */       MapUtils.addPercentToMap(params, "name", 
/*  60 */         RequestUtils.getString(request, "name"));
/*  61 */       MapUtils.addToMap(params, "cityId", 
/*  62 */         RequestUtils.getLong(request, "cityId"));
/*  63 */       MapUtils.addToMap(params, "status", 
/*  64 */         RequestUtils.getInt(request, "status"));
/*     */ 
/*  66 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  67 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  69 */       logger.error(e);
/*  70 */       ResponseUtils.setErrorMsgResponse(
/*  71 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  79 */       Map params = new HashMap();
/*     */ 
/*  81 */       MapUtils.addToMap(params, "id", id);
/*  82 */       MapUtils.addPercentToMap(params, "code", 
/*  83 */         RequestUtils.getString(request, "code"));
/*  84 */       MapUtils.addPercentToMap(params, "name", 
/*  85 */         RequestUtils.getString(request, "name"));
/*  86 */       MapUtils.addToMap(params, "cityId", 
/*  87 */         RequestUtils.getLong(request, "cityId"));
/*  88 */       MapUtils.addToMap(params, "status", 
/*  89 */         RequestUtils.getInt(request, "status"));
/*     */ 
/*  91 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/*  92 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  94 */       logger.error(e);
/*  95 */       ResponseUtils.setErrorMsgResponse(
/*  96 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 106 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 108 */       Map params = new HashMap();
/*     */ 
/* 110 */       MapUtils.addToMap(params, "id", 
/* 111 */         RequestUtils.getInt(request, "status"));
/* 112 */       MapUtils.addPercentToMap(params, "code", 
/* 113 */         RequestUtils.getString(request, "code"));
/* 114 */       MapUtils.addPercentToMap(params, "name", 
/* 115 */         RequestUtils.getString(request, "name"));
/* 116 */       MapUtils.addToMap(params, "cityId", 
/* 117 */         RequestUtils.getLong(request, "cityId"));
/* 118 */       MapUtils.addToMap(params, "status", 
/* 119 */         RequestUtils.getInt(request, "status"));
/*     */ 
/* 121 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 122 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 124 */       logger.error(e);
/* 125 */       ResponseUtils.setErrorMsgResponse(
/* 126 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 145 */       int nResult = 0;
/* 146 */       String sData = RequestUtils.getStringOfData(request);
/* 147 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 148 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 149 */         for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/* 150 */           if (((GsonHeadOneRow)p.getListInsertRows().get(i)).getValueOfName("status") != null) continue;
/* 151 */           ((GsonHeadOneRow)p.getListInsertRows().get(i))
/* 152 */             .autoAddHeadData("status", Integer.valueOf(0));
/*     */         }
/*     */ 
/* 155 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/*     */ 
/* 158 */       if (nResult > 0)
/* 159 */         DbConnection.commit();
/*     */       else {
/* 161 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 164 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 165 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 166 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 169 */       logger.error(e);
/* 170 */       DbConnection.rollback();
/* 171 */       ResponseUtils.setErrorMsgResponse(
/* 172 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 173 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 192 */       int nResult = 0;
/* 193 */       String sData = RequestUtils.getStringOfData(request);
/* 194 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 195 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 196 */         for (int i = 0; i < p.getListUpdateRows().size(); ++i) {
/* 197 */           if (((GsonHeadOneRow)p.getListUpdateRows().get(i)).getValueOfName("id") == null) {
/* 198 */             ((GsonHeadOneRow)p.getListUpdateRows().get(i)).autoAddHeadData("id", id);
/*     */           }
/*     */         }
/*     */ 
/* 202 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 204 */       if (nResult > 0)
/* 205 */         DbConnection.commit();
/*     */       else {
/* 207 */         DbConnection.rollback();
/*     */       }
/* 209 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 210 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 211 */         response);
/*     */     } catch (Exception e) {
/* 213 */       logger.error(e);
/* 214 */       DbConnection.rollback();
/* 215 */       ResponseUtils.setErrorMsgResponse(
/* 216 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 217 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 233 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 235 */       String[] strParams = id.split(",");
/* 236 */       int nResult = this.dao.deleteParams(strParams);
/* 237 */       if (nResult > 0)
/* 238 */         DbConnection.commit();
/*     */       else {
/* 240 */         DbConnection.rollback();
/*     */       }
/* 242 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 243 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 244 */         response);
/*     */     } catch (Exception e) {
/* 246 */       DbConnection.rollback();
/* 247 */       logger.error(e);
/* 248 */       ResponseUtils.setErrorMsgResponse(
/* 249 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 250 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.supplier.controller.SupplierController
 * JD-Core Version:    0.5.3
 */